#pragma once
#include <iostream>
#include <vector>
#include <ctime>

void PrintLog()
{
    std::cout << "Print Log" << std::endl;
}

void Download()
{
    std::cout << "Download" << std::endl;
}

void Upload()
{
    std::cout << "Upload" << std::endl;
}

typedef void (*task_t)();

class TaskManager
{
public:
    // 随机数种子
    TaskManager()
    {
        srand(time(nullptr));
    }

    // 注册新任务
    void TaskRegister(task_t task)
    {
        _tasks.push_back(task);
    }

    // 生成任务代码
    int code()
    {
        return rand() % _tasks.size();
    }

    // 执行任务
    void TaskExecute(int code)
    {
        if (code >= 0 && code < _tasks.size())
        {
            _tasks[code]();
        }
    }

private:
    std::vector<task_t> _tasks;
};